var util = require('../../utils/util.js');
const md = require('../../utils/md5.js');
const app = getApp();
const post = require('../../utils/post.js');
Page({

  data: {
    types:null
  },
  onLoad: function (options) {
    var that = this;
    var id = options.id;
    var types = options.type;
    if(types){
      this.setData({
        types:types
      })
      if (id) {
        that.yingye(id);
      }
    }else{
      if (id) {
        that.chushi(id);
      }
    }
   
  },
  chushi: function (id) {
    var that = this;
    var datas = {};
    datas.where = "TRID = " + id;
    var datacall = function (res) {
      console.log(res);
      if (res.data.data.length != 0) {
        var data = res.data.data[0];
        // data.ToPhotoUrl = data.PhotoUrl;
        data.MnyHap2 = (data.MnyGet ? data.MnyGet : 0) - (data.MnyPay ? data.MnyPay : 0);
        that.setData({
          billinfo: data
        })
      }
    }
    var res2 = post.getdata("/BO/TR_Detail/Query", datas, datacall);
  },
  yingye:function(id){
    var that = this;
    var datas = {};
    datas.where = "SBVID = " + id;
    var datacall = function (res) {
      console.log(res);
      if (res.data.data.length != 0) {
        var data = res.data.data[0];
        data._CreateTime = data.BVDate;
        // data.TranNo = data.BVCode;
        data.SrcCode = data.BVCode;
        // data.TranName = data.SrcName;
        data.MnyHap = data.MoneySum;
        // data.PhotoUrl = "/images/" + data.PayType+".png";
        data.ToMebName = "营业收入";
        data.ToPhotoUrl = data.PayIcon;
        that.setData({
          billinfo: data
        })
      }
    }
    var res2 = post.getdata("/BO/SA_BillVouch/Query", datas, datacall);
  }
})